﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            class1 cs = new class1();
            ArrayList list = new ArrayList();
            while (true)
            {


                Console.WriteLine("1、添加学生信息。2、查询学生信息，3、删除学生信息。");
                int a = int.Parse(Console.ReadLine());

                switch (a)
                {
                    case 1:
                        Console.WriteLine("输入你的学号");
                        string aa = Console.ReadLine();
                        Console.WriteLine("输入你的姓名");
                        string b = Console.ReadLine();
                        Console.WriteLine("输入你的年龄");
                        string c = Console.ReadLine();
                        class1 stu = new class1(aa, b, c);
                        list.Add(stu);
                        break;
                    case 2:
                        
                        
                            Console.WriteLine("请选择排序方式：1、按姓名排；2、按年龄排；3、按学号排；");

                            int num = int.Parse(Console.ReadLine());
                            IComparer<class1> comparer;
                            switch (num)
                            {
                                case 1:
                                    comparer = new name();
                                    break;
                                case 2:
                                    comparer = new age();
                                    break;
                                case 3:
                                    comparer = new id();
                                    break;

                            }
                            list.Sort();

                            for (int i = 0; i < list.Count; i++)
                            {
                                student st = (student)list[i];
                                Console.WriteLine("学号:{0},姓名:{1}，年龄:{2}", cs.Id, cs.Name, cs.Age);
                            }
                        

                        break;
                    case 3:
                        Console.WriteLine("请输入学号：");
                        int num1 = int.Parse(Console.ReadLine());
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list.Contains(cs.Id)==true )
                            {
                                list.RemoveAt(num1);
                            }
                            else
                            {
                                Console.WriteLine("没这个学号");
                            }
                                
                                
                            
                           
                        }
                            break;
                }
            }
        }
    }
}
